#ifndef __OGAME_SCENE_H__
#define __OGAME_SCENE_H__

class oGameScene: public oPlatformWorld, public CCTextFieldDelegate
{
public:
	oGameScene();
	virtual ~oGameScene();
	static CCScene* scene();
	virtual bool init();
	virtual void update(ccTime dt);
	void start(int heroId = 0);
	void loadResource();
	void unloadResource();
	void createCastles();
	void destroyCastles();
	void destroyBunnies();
	void createReadmeItems();
	void destroyReadmeItems();
	static void createSwitcher(bool isMe);
	void onHeroMeHpChange(oUnit* owner, float oldValue, float newValue);
	void onRiseHero(CCNode* node, void* data);
	LAYER_NODE_FUNC(oGameScene);
	static void setMana(oGroup* group, float mana);
	static void addMana(oGroup* group, float mana);
	static float getMana(oGroup* group);
	static bool isWin(oGroup* group);
	static void win(oGroup* group);
	static bool isGameOver;
	static oUnit* heroMe;
	static oUnit* heroEnemy;
	static oUnit* switcherMe[2];
	static oUnit* switcherEnemy[2];
	static int bunnyMeCount;
	static int bunnyEnemyCount;
	static int brickMeCount;
	static int brickEnemyCount;
	static bool isMeAttacked;
	static bool isEnemyAttacked;
	static oGameScene* instance();
private:
	int _selectHeroId;
	static oGameScene* _intance;
	virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);
	virtual void keyBackClicked();
	virtual void keyMenuClicked();
	void onClickConfirm(CCObject* pSender);
	void onClickQuit(CCObject* pSender);
	void onClickBack(CCObject* pSender);
	void onClickBackToWelcome(CCObject* pSender);
	void onClickStart(CCObject* pSender);
	void onClickShare(CCObject* pSender);
	void onSelectFlandre(CCObject* pSender);
	void onSelectDorothy(CCObject* pSender);
	void onSelectVilly(CCObject* pSender);
	void selectedHero();
	void onGameBegin();
	CCSprite* _panel;
// 	CCSprite* _mana_rim;
// 	CCSprite* _mana_show;
	CCMenu* _welcomeMenu;
	CCMenu* _selectMenu;
	CCMenu* _keyLR;
	CCMenu* _keyFU;
	CCMenu* _shareEsc;
	oModel* _hpShow;
	CCTextFieldTTF* _txtId;
	CCTextFieldTTF* _txtPassword;
	static bool _isMeWin;
	static float _manaMe;
	static float _manaEnemy;
	bool _isLoaded;
	float _scale;
	float _actualScreenWidth;
	float _actualScreenHeight;
	void updateLoadResource(ccTime dt);
	oUnit* _unit;
};

#endif
